<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script language="javascript">
	function ouputcsv()
	{
		$("#if_csv").val(1);
		$("#search").submit();
	}
	function apply2price() {
		if(confirm("确定申请议价?")){
			var str = selectallpro();
			if(str !=false)
			{
				$.post("/factory/ajaxbutton", {"op": "apply2price","ids":str},
						function(data){
							if(data==200)
							{
								alert("申请成功!");
								window.location.reload();
							}
						},"text");
			}

		}
	}
	function changePrice(id,flag) {
		if(flag==1){
			//维持原价
			if(confirm("确定维持原价?")){
				$.post("/factory/ajaxbutton", {"op": "changePrice","id":id,"flag":1},
						function(data){
							if(data==200)
							{
								alert("执行成功!");
								window.location.reload();
							}
						},"text");
			}
		}
		if(flag==2){
			$("#factory_sell_id").val(id);
			$("#changepriceform").show();
		}
		if(flag==3){
			//修改价格
			var price = $("#price").val();
			$.post("/factory/ajaxbutton", {"op": "changePrice","id":id,"flag":3,"price":price},
					function(data){
						if(data==200)
						{
							alert("修改成功!");
							window.location.reload();
						}else if(data==201){
							alert("修改后的价格，不能大于原成本价");return false;
						}
					},"text");
		}

	}
</script>
<title>出货记录报表</title>
<body class="withvernav">
<div class="bodywrapper">
	{{include file='/public/leftmenu.tpl'}}
	<div class="centercontent">
		<div class="pageheader notab">
			<h1 class="pagetitle">出货记录报表</h1>
			<span class="pagedesc">销售利润率 =( 订单价格-平台费-支付费-估计运费 - 出厂价) / (订单价格-平台费-支付费-估计运费) </span>
			<div class="menulist">
				<ul class="profile_summary">
				</ul>
			</div>
		</div>
		<!--pageheader-->
		<div id="contentwrapper" class="contentwrapper">
			<div id="basicform" class="subcontent">
				<!--搜索栏-->
				<div>
					<div style="float:left;">
					</div>
					<div class="page">{{$pageList}} 计{{$total}}条记录，共{{$totalpage}}页</div>
				</div>
				<form class="stdform stdform2" method="get" id="search" action="/factory/ajaxbutton">
					<input type='hidden' name='if_csv' id='if_csv'>
					<input type="hidden" name = "op" value="applypricelist">
					<div class="tableoptions">
						<select name="fID" id="fID"  class="selection " style="width:100px;" >
							<option value="" >工厂</option>

							{{foreach from=$factorylist item=li key=key}}
							{{if $li.name=='外采购'}}
							{{else}}
							<option value="{{$li.id}}" {{if $li.id==$fID}} selected{{/if}}>{{$li.name}}</option>
							{{/if}}
							{{/foreach}}

						</select>

						下单时间
						<input type="text"  name="starttime" value="{{$starttime}} " onClick="WdatePicker({dateFmt:'yyyy-MM-dd '})" class="width100 hasDatepicker" />
						-
						<input type="text"  name="endtime" value="{{$endtime}} " onClick="WdatePicker({dateFmt:'yyyy-MM-dd '})" class="width100 hasDatepicker" />
						&nbsp;

						完成时间
						<input type="text"  name="o_starttime" value="{{$o_starttime}} " onClick="WdatePicker({dateFmt:'yyyy-MM-dd '})" class="width100 hasDatepicker" />
						-
						<input type="text"  name="o_endtime" value="{{$o_endtime}} " onClick="WdatePicker({dateFmt:'yyyy-MM-dd '})" class="width100 hasDatepicker" />
						&nbsp;
						商品编号: <input type="text" name="other" id="other" class="width200" value="{{$other}}" placeholder="" />

						<select name="ls" id="searchtype" class="selection" style="width:100px;" >
							<option value="0" >利润率查询</option>
							<option value="1"   {{if $ls==1}} selected{{/if}}>负利润率(小于0)</option>
							<option value="2" {{if $ls==2}} selected{{/if}}>低利润率(0-0.1)</option>
							<option value="3" {{if $ls==3}} selected{{/if}} >利润率为-∞</option>

						</select>
						&nbsp;
						利润率小于: <input type="text" name="lv" id="lv" class="width100" value="{{$lv}}" placeholder="" />
						&nbsp;
						状态：
						<select name="status" id="status" class="selection" style="width:100px;" >
							<option value="0" >选择状态</option>
							<option value="1"   {{if $status==1}} selected{{/if}}>申请议价</option>
							<option value="2" {{if $status==2}} selected{{/if}}>维持原价</option>
							<option value="3" {{if $status==3}} selected{{/if}} >修改价格</option>

						</select>
						<button class="btn btn-primary" id="searchbtn">Search</button>
						{{if $managers || in_array('104',$showpower)}}
						&nbsp;&nbsp;&nbsp;&nbsp;<button onClick="ouputcsv()"  class="stdbtn btn_black">导出</button>
						{{/if}} </div>
				</form>
				<!--搜索栏结束-->
				<table cellpadding="0" cellspacing="0" border="0" class="stdtable" style="table-layout: fixed;">
					<thead>
					<tr class="lbbt">
						<td width="5%" bgcolor="#FEFFF1"><a onClick="allSelect('ppid[]')">全选</a></td>
						<td bgcolor="#FEFFF1">订单编号</td>
						<td bgcolor="#FEFFF1">完成时间</td>
						<td bgcolor="#FEFFF1">订单时间</td>
						<td bgcolor="#FEFFF1" width="60">生产方式</td>
						<td bgcolor="#FEFFF1">商品编号</td>

						<!--          <td bgcolor="#FEFFF1">商品名称</td>
						-->          <td bgcolor="#FEFFF1">订单价格</td>
						<td bgcolor="#FEFFF1">订单重量(KG)</td>
						<td bgcolor="#FEFFF1">估计运费</td>
						<td bgcolor="#FEFFF1">销售利润率</td>
						<td bgcolor="#FEFFF1">出厂价</td>
						<td bgcolor="#FEFFF1">工厂</td>
						<td bgcolor="#FEFFF1">备注</td>
						<td bgcolor="#FEFFF1">操作</td>
					</tr>
					</thead>
					<tbody >

					{{foreach from=$orderlist item=li key=key}}
					<tr>
						<td><input name="ppid[]" type="checkbox" class="none" id="ppid[]" value="{{$li.id}}"/></td>
						<td valign="middle"  style="position:relative;"><a href="/factory/orderdetail?id={{$li.orderId}}" target="_blank"><font color="#6666FF">{{$li.ordernumber}}</font></a> {{if $managers || $userdepartment==3}} &nbsp;&nbsp;&nbsp;
							<a href="/orderlist/editorder?sn={{$li.mabangorderid}}" target="_blank"><img src="/fuman/images/icons/attachment.png"><span id="tip_info">订单信息</span></a>
							{{/if}}</td>
						<td valign="middle" >{{$li.finshtime}}</td>
						<td valign="middle" >{{$li.orderTime}}</td>
						<td valign="middle" >
							{{if $li.custom==1}}均码{{/if}}
							{{if $li.custom==2}}定制{{/if}}
							{{if $li.custom==3}}配件{{/if}}</td>
						<td   style="position:relative;"><a href="/product/showproduct?goods_id={{$li.skuID}}" target="_blank"><font color="#6666FF">{{$li.goods_sku}}</font></a>

							{{if $li.loglist}}
							<a href="/factory/ajaxbutton?if_csv=0&op=costpricelog&other={{$li.goods_sku}}" target="_blank"><img src="/fuman/images/icons/ebaynote.png"><span id="tip_info">
          	{{$li.loglist}}<br>
         </span></a>
							{{/if}}

						</td>
						<!--<td valign="middle"  style="width: 50px; overflow:hidden;white-space:nowrap; text-overflow:ellipsis;" >{{$li.skuName}}</td>-->
						<td valign="middle" >{{$li.money}}</td>
						<td  class="cz">{{$li.scale}}</td>
						<td  class="cz">{{$li.shipingfee}}</td>
						<td  class="cz">{{$li.lv}}</td>
						<td  class="cz">{{$li.g_costprice}}</td>
						<td  class="cz">{{$li.factoryl}}</td>
						<td>
							{{if $managers || $userclassid ==11}}
							<span style="cursor:pointer" onClick="listTable.edit(this, 'factoryorderremark','{{$li.id}}','{{$li.remark}}')">{{if $li.remark}}{{$li.remark}}{{else}}<font color="#CCCCCC">编辑备注</font>{{/if}}</span>
							{{else}}
							{{$li.remark}}
							{{/if}}

						</td>
						<td  class="cz">
							{{if $li.statuses ==1}}
				                {{if $managers || $userclassid == 12 || $userclassid == 13}}
				                    <a href="javascript:void(0)" onClick="changePrice({{$li.id}},1);return false;"> <button class="stdbtn">维持原价</button></a>
				                    <br/>
				                    <a href="javascript:void(0)" onClick="changePrice({{$li.id}},2);return false;"> <button class="stdbtn">修改价格</button></a>
				                {{/if}}
							{{/if}}
						</td>
					</tr>
					{{/foreach}}

					</tbody>

				</table>
				<div class="page">{{$pageList}} 计{{$total}}条记录，共{{$totalpage}}页</div>
			</div>
		</div>
		<!-- 修改价格弹出框-->
		<!-- 模态框（Modal）交运内容 -->
		<form action="/factory/ajaxbutton" enctype="multipart/form-data" method="post" name="changepriceattributeform" id="changepriceattributeform" style="font-size: 16px;color: #666;line-height: 21px;font-family: Helvetica, 'Hiragino Sans GB', 'Microsoft Yahei', '微软雅黑', Arial, sans-serif;">
			<div class="modal fade" id="changepriceform" tabindex="-1" role="dialog" aria-labelledby="sexpressform" aria-hidden="true" style="margin-top: 60px;padding-top:60px;">
				<div class="modal-dialog">
					<div class="modal-content">
						<div class="modal-header">
							<button type="button" class="close" data-dismiss="modal"
							        aria-hidden="true" onClick="javascript:$('#changepriceform').hide();">× </button>
							<h4 class="modal-title"><span id="order_mailno">修改出厂价格</span></h4>
						</div>
						<div class="modal-body">
							<table width="100%" border="0" cellspacing="0" cellpadding="0">
								<tr>
									<td width="100">修改价格： </td>
									<td align="left">
										<input type="text" name="price" id = "price" value="">
									</td>
								</tr>
							</table>
							<div class="modal-footer">
								<button type="button" class="btn btn-default"
								        data-dismiss="modal" style="display:none"> 关闭 </button>
								<input type="hidden" id="op" name="op" value="changePrice">
								<input type="hidden" name="factory_sell_id" id="factory_sell_id" value="">
								<button type="button" class="btn btn-primary"  onclick="changePrice($('#factory_sell_id').val(),3)">确认修改</button>
							</div>
						</div>
						<!-- /.modal-content -->
					</div>
					<!-- /.modal-dialog -->
				</div>
			</div>
		</form>
		<!-- /.modal -->
</body>
</html>